package com.zzyl.controller;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.RetreatDto;
import com.zzyl.service.RetreatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/elder")
@Api(tags = "退住")
public class RetreatController {
    @Autowired
    private RetreatService retreatService;

    @PutMapping("/cancel")
    @ApiOperation("撤销")
    public ResponseResult cancel(
           @RequestParam String retreatCode,
           @RequestParam String taskId
    ){
        return retreatService.cancel(retreatCode,taskId);
    }

    /**
     * 驳回
     * @param retreatCode 退住申请编号
     * @param taskId 任务编号
     * @param message 驳回原因
     * @return 响应结果
     */
    @PutMapping
    @ApiOperation("驳回")
    public ResponseResult reject(
            @RequestParam String retreatCode,
            @RequestParam String taskId,
            @RequestParam String message
    ){
       return retreatService.reject(message,retreatCode,taskId);

    }

    /**
     * 提交退住申请审批
     * @param retreatDto 退住申请审批
     * @return 响应结果
     */
    @PostMapping("/submit")
    @ApiOperation(value = "提交")
    public ResponseResult submitRetreat(
            @RequestBody RetreatDto retreatDto) {
        return retreatService.submitRetreat(retreatDto);
    }
}
